/**
 * Created by lighter on 2014/12/20.
 */
package Hxw3DEngine.asset.parsers.bson.vo {
import flash.utils.ByteArray;

public class SkeletonAnim {

    // 动画帧类型
    public static const frame_key:uint = 0;         // 关键帧
    public static const frame_sequence:uint = 1;    // 序列帧

    // 动画矩阵类型
    public static const mtx_data_matrix12:uint = 1;	       // 01	12浮点数矩阵
    public static const mtx_data_pos_rot:uint = 2;	       // 10	位置+旋转四元数 7浮点数
    public static const mtx_data_pos_rot_scale:uint = 3;    // 11	位置+旋转四元数+缩放 10浮点数

    public static const mtx_world:uint = 1 << 3;			   // 100	 1为世界坐标 0为局部坐标
    public static const mtx_data_mask:uint = 3;

    public static const FLOAT_LENGTH:uint = 4;

    public var frame_type:uint;
    public var frames:uint;
    public var duration:uint;
    public var track_type:uint;
    public var joints:uint;
    public var tracks:ByteArray;

    public var keyLength:uint;

    public function SkeletonAnim(obj:Object) {
        frame_type = obj.frame_type;
        frames = obj.frames;
        duration = obj.duration;
        track_type = obj.track_type;
        joints = obj.joints;
        tracks = obj.tracks.data;

        switch(track_type & mtx_data_mask){
            case mtx_data_matrix12:
                keyLength =  FLOAT_LENGTH * 12;
                break;
            case mtx_data_pos_rot:
                keyLength =  FLOAT_LENGTH * (3+4);
                break;
            case mtx_data_pos_rot_scale:
                keyLength =  FLOAT_LENGTH * (3+4+3);
                break;
        }
    }

    public static function create(obj:Object):Object{
        return new SkeletonAnim(obj);
    }
}
}
